CreateTemplateStartForm = function(config) {

    // Privatne varijable
    var privateVariable = '';

    this.valueData = {};
    this.formConfig = {};

    var templatesTemplateStore =  new Ext.data.JsonStore( {
        proxy : new Ext.data.HttpProxy( {
            url : 'mvc/templatesTemplate',
            method : 'GET'
        }),
        root : 'data',
        idProperty : 'id',
        fields : [ 'id', 'name' ]
    });

    Ext.apply(this, config || {}, {
        title: 'Kreiranje predloška'
    });

    Ext.applyIf(this.formConfig, {
        monitorValid:true,
        items : [{
                    xtype : 'abstractComboBox',
                    fieldLabel : 'Predložak',
                    name : 'apis:templatesTemplateId',
                    hiddenName : 'apis:templatesTemplateId',
                    store : templatesTemplateStore,
                    valueField : 'id',
                    displayField : 'name',
                    allowBlank : false
                 }, {
                     xtype : 'textfield',
                     name : 'cmis:name',
                     fieldLabel : 'Naziv',
                     allowBlank : false
                 }, {
                     xtype: 'textarea',
                     fieldLabel: 'Napomena',
                     name:'bpmn_comment'
                 }, {
                     xtype : 'hidden',
                     name : 'cmis:objectTypeId',
                     value : 'D:apis:templateDocument'
                 }, {
                     xtype : 'hidden',
                     name : 'apis:groupId',
                     value : 'TODO'
                 }, {
                     xtype : 'hidden',
                     name : 'processId',
                     value : 'kreirajPredložak'
                 }
        ],
        buttons: [{
            text: 'Pošalji',
            handler: this.onSend,
            scale:'medium',
            iconCls: 'button-form-upload',
            formBind: true,
            scope : this
        }, {
            text : 'Odustani',
            handler :this.close,
            scale:'medium',
            iconCls: 'button-form-cancel',
            scope : this
        }]
    });

    // Poziv konstruktora nadklase
    CreateTemplateStartForm.superclass.constructor.call(this);

};

Ext.extend(CreateTemplateStartForm, AbstractForm, {

    onSend : function(){
        this.getForm().submit( {
            url : 'mvc/start/form/createTemplate',
            method : 'POST',
            scope : this,
            success : function(response, options) {
                var jsonData = Ext.util.JSON.decode(options.response.responseText);
                this.close();
                window.open(jsonData.downloadUrl);
            },
            //failure : function(){alert("Greška!");},
            waitTitle : 'Molim pričekajte',
            waitMsg : 'Spremam!',
            submitEmptyText : false,
            clientValidation : false
        });
    }
});

Ext.reg('createTemplateStartForm', CreateTemplateStartForm);